package com.heima.article.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApChannelSizeMapper;
import com.heima.article.service.ApChannelSizeService;
import com.heima.model.article.pojos.ApArticle;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ApChannelSizeServiceImpl extends ServiceImpl<ApChannelSizeMapper, ApArticle> implements ApChannelSizeService {

    private final ApChannelSizeMapper channelSizeMapper;

    @Override
    public Integer channelSize(Integer channelId) {
        LambdaQueryWrapper<ApArticle> wrapper = Wrappers.<ApArticle>lambdaQuery()
                .eq(channelId != null, ApArticle::getChannelId, channelId);
        Integer size = channelSizeMapper.selectList(wrapper).size();
        return size;
    }
}
